package com.ctvit.sjk.knowledge.dataset.pojo.vo;

import com.alibaba.fastjson2.JSONObject;
import com.ctvit.sjk.knowledge.dataset.pojo.domain.TabDataset;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.Collections;
import java.util.List;

/**
 * 知识库VO
 *
 * @author heyingcheng
 * @date 2025/03/24
 */
@Getter
@Setter
@ToString
public class DatasetGetVO {

    private String id;

    private String name;

    private String desc;

    private String type;

    private JSONObject meta;

    @JsonProperty("embedding_mode_id")
    protected String embeddingModelId;

    @JsonProperty("user_id")
    private String userId;

    @JsonProperty("char_length")
    private Integer charLength;

    @JsonProperty("application_mapping_count")
    private Integer applicationMappingCount;

    @JsonProperty("document_count")
    private Integer documentCount;

    @JsonProperty("application_id_list")
    private List<String> applicationIdList;

    public DatasetGetVO(TabDataset entity) {
        this(entity, Collections.emptyList());
    }

    public DatasetGetVO(TabDataset entity, List<String> appIdList) {
        this.id = entity.getDatasetId();
        this.name = entity.getDatasetName();
        this.desc = entity.getDatasetDesc();
        this.type = entity.getDatasetType();
        this.meta = JSONObject.parseObject(entity.getMetadata());
        this.embeddingModelId = entity.getEmbeddingModelId();
        this.userId = entity.getCreateId();
        this.charLength = 0;
        this.applicationMappingCount = 0;
        this.documentCount = 0;
        this.applicationIdList = appIdList;
    }

}
